home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18491 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  59 lines

  1. Path: raven.eva.net!usenet
  2. From: joebwan@anv.net (Joe Bostic)
  3. Newsgroups: comp.lang.c++
  4. Subject: Did Borland 5.0 break templates (ouch!)
  5. Date: Sun, 21 Apr 1996 02:02:01 GMT
  6. Organization: Westwood Studios
  7. Message-ID: <3179962c.126789194@news.accessnv.com>
  8. NNTP-Posting-Host: joebwan.anv.net
  9. X-Newsreader: Forte Agent .99d/32.182
  10.  
  11. ... or is it just me. I'm trying to use a template that takes an
  12. integer parameter. I would like to declare the body of the member
  13. functions outside of the template declaration (a normal and legal
  14. request). However, the following code fails using Borland 5.0 compiler
  15. (16 or 32 bit). I've reverted back to 4.52 (which compiles just fine)
  16. until I know whether I should get mad at Borland or kick myself for
  17. not understanding some mysterious new 'feature' of the C++ standard
  18. that Borland is implementing.
  19.  
  20. ------------ Code to demonstrate problem -----------------------
  21.  
  22. template<int T>
  23. class Test {
  24.     public:
  25.         void Simple(void);
  26.         Test const & Foobar(Test const & rvalue);
  27.         Test const & operator | (Test const & rvalue);
  28. };
  29.  
  30.  
  31. template<int T>
  32. void Test<T>::Simple(void)
  33. {
  34. }
  35.  
  36. // "invalid template qualified name" error.
  37. // if the "Test<T>::" is removed it compiles but linker
  38. // can't find the "Foobar" function.
  39. template<int T>
  40. Test<T> const & Test<T>::Foobar(Test<T> const & rvalue)
  41. {
  42.     return(*this);
  43. }
  44.  
  45. template<int T>
  46. Test<T> const & operator | (Test<T> const & rvalue)
  47. {
  48.     return(*this);
  49. }
  50.  
  51. void main(void)
  52. {
  53.     Test<100> x;
  54.  
  55.     x.Foobar(x);
  56.     x = x | x;            // Linker can't find function!
  57.     x.Simple();            // No problem with this line.
  58. }
  59.